<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="message" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="supplierUpdateSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>更新</el-button>
          <el-button @click="gotoPage('6C772D4230F44BCAAEBE132AB37A9075?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 修改主要信息 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户类型" prop="client_type">
                  <el-select style='width:100%' v-model="message.client_type">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clienttype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="分类" prop="client_class">
                  <el-radio-group v-model="message.client_class">
                    <el-radio-button label="组织">组织</el-radio-button>
                    <el-radio-button label="个人">个人</el-radio-button>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户名称 " prop="client_name">
                  <el-input v-model="message.client_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户代码" prop="client_codename">
                  <el-input v-model="message.client_codename" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="状态" prop="client_mode">
                  <el-select style='width:100%' v-model="message.client_mode">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clientmode" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="信息来源" prop="client_origin">
                  <el-select style='width:100%' v-model="message.client_origin">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clientorigin" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户等级" prop="client_rate">
                  <el-select style='width:100%' v-model="message.client_rate">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clientrate" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户号码" prop="client_no">
                  <el-input v-model="message.client_no" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="网站地址" prop="client_net">
                  <el-input v-model="message.client_net" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="行业" prop="client_bus">
                  <el-select style='width:100%' v-model="message.client_bus">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in clientbus" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="提醒描述" prop="client_remind">
                  <el-input v-model="message.client_remind" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="提醒日期 " prop="client_reminddate">
                  <el-date-picker v-model="message.client_reminddate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 电话号码 </span>
          </div>
          <el-table :data="phone">
            <el-table-column label="电话" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="phones_type" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.phones_type">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in phonetype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="号码" prop="phones_number">
              <template slot-scope="scope">
                <el-input v-model="scope.row.phones_number" />
              </template>
            </el-table-column>
            <el-table-column label="分机" prop="phones_extension">
              <template slot-scope="scope">
                <el-input v-model="scope.row.phones_extension" />
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 电子邮件地址 </span>
          </div>
          <el-table :data="email_info">
            <el-table-column label="电话" prop="">
            </el-table-column>
            <el-table-column label="类型" prop="email_type" 类型>
              <template slot-scope="scope">
                <el-select style='width:100%' v-model="scope.row.email_type">
                  <el-option label="－－无－－" value='' />
                  <el-option v-for="dict in emailtype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="号码" prop="email_address">
              <template slot-scope="scope">
                <el-input v-model="scope.row.email_address" />
              </template>
            </el-table-column>
          </el-table>
          <div class="form-unit">
            <span class="mvc-title-left"> 地址 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="类型" prop="">
                  <el-select style='width:100%' v-model="empty">
                    <el-option label="主要的" value="主要的" />
                    <el-option label="辅助的" value="辅助的" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-radio-group v-model="address.address_type">
                  <el-radio-button label="基本">基本</el-radio-button>
                </el-radio-group>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="地址行" prop="address_info">
                  <el-input type="textarea" v-model="address.address_info" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="城市" prop="address_city">
                  <el-input v-model="address.address_city" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="省" prop="address_province">
                  <el-input v-model="address.address_province" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="邮政编码" prop="address_postcode">
                  <el-input v-model="address.address_postcode" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="国家" prop="address_nation">
                  <el-select style='width:100%' v-model="address.address_nation">
                    <el-option label="CHINA PEOPLE REP" value="CHINA PEOPLE REP" />
                    <el-option label="..." value="..." />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="国家" prop="">
                  <el-input v-model="empty" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="纬度" prop="address_latitude">
                  <el-input v-model="address.address_latitude" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="经度" prop="address_longitude">
                  <el-input v-model="address.address_longitude" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 额外明细 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="client_remark">
                  <el-input type="textarea" v-model="message.client_remark" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="supplierUpdateSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>更新</el-button>
          <el-button @click="gotoPage('6C772D4230F44BCAAEBE132AB37A9075?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'基本信息'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'SupplierUpdate',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        message: {
          client_type: null,
          client_class: null,
          client_name: null,
          client_codename: null,
          client_mode: null,
          client_origin: null,
          client_rate: null,
          client_no: null,
          client_net: null,
          client_bus: null,
          client_remind: null,
          client_reminddate: null,
        },
        phone: [],
        email_info: [],
        address: {
          address_type: null,
          address_info: null,
          address_city: null,
          address_province: null,
          address_postcode: null,
          address_nation: null,
          address_latitude: null,
          address_longitude: null,
          client_remark: null,
        },
        clienttype: [],
        clientmode: [],
        clientorigin: [],
        clientrate: [],
        clientbus: [],
        phonetype: [],
        emailtype: [],
        loading: false,
        Container: null,
        rules: {
          client_name: [{
            required: true,
            message: "客户名称 不能为空",
            trigger: 'blur',
          }],
          client_no: [{
            required: true,
            message: "客户号码不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "基本信息"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierUpdate/supplierUpdate?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      supplierUpdateSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/SupplierUpdate/supplierUpdateSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
